public class Num9 {
    public boolean isPalindrome(int x) {
        return x >= 0 && x == reverse(x);
    }

    private int reverse(int x){
        long res = 0;
        int temp;
        while (x != 0) {
            temp = x % 10;
            x = (x - (x % 10)) / 10;
            res = res * 10 + temp;
        }
        return res > Integer.MAX_VALUE ? 0 : (int)res;
    }

    public static void main(String[] args) {
        Num9 num9 = new Num9();
        System.out.println(num9.isPalindrome(122));
    }
}
